//
//  DetailsViewController.m
//  CarOfHome2
//
//  Created by 微 醺 on 15/9/23.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DetailsViewController.h"
#import "Hot_todView.h"
#import "DetailsCollectionViewCell.h"
#import "CollectionModel.h"
#import "AppDelegate.h"

@interface DetailsViewController () <UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, strong) UIButton *backButton;
@property (nonatomic, strong) Hot_todView *rod;

@end

@implementation DetailsViewController

- (void)viewWillAppear:(BOOL)animated{
    
    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.view.backgroundColor = [UIColor blackColor];
        self.rod.collectView.backgroundColor = [UIColor blackColor];
        [self.rod.collectView reloadData];
    }
    else{
        self.view.backgroundColor = [UIColor whiteColor];
        self.rod.collectView.backgroundColor = [UIColor whiteColor ];
        [self.rod.collectView reloadData];
    }
}
//隐藏StatusBar
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleDefault;
    //UIStatusBarStyleDefault = 0 黑色文字，浅色背景时使用
//    return UIStatusBarStyleLightContent = 1 白色文字，深色背景时使用
}

- (BOOL)prefersStatusBarHidden
{
    return YES; // 返回NO表示要显示，返回YES将hiden
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    //隐藏navigationBar
    self.navigationController.navigationBarHidden = YES;
    //隐藏tabBar
    self.tabBarController.tabBar.hidden = YES;

    [self collectionViewSubView];
    [self logo];
}


- (void)logo
{
    self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.backButton.frame = CGRectMake(SAWindth *15, SAHeight * 15, SAWindth *30, SAHeight * 30);
    self.backButton.layer.cornerRadius = 15;
    self.backButton.backgroundColor = [UIColor blackColor];
    self.backButton.alpha = 0.5;
    [self.backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [self.view addSubview:self.backButton];
    [self.backButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)back:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)collectionViewSubView
{
    self.rod = [[Hot_todView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
   self.rod.collectView.dataSource = self;
    self.rod.collectView.delegate = self;
    self.rod.collectView.bounces = NO;//关闭边界反弹
    [self.view addSubview:self.rod];
    [self.rod.collectView registerClass:[DetailsCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return [self.numArr count];
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    DetailsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse"forIndexPath:indexPath];
    cell.index = self.index;
    NSDictionary *dic = self.numArr[indexPath.item];
    cell.dic = dic;
    
    return cell;
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
